package net.yeah.mickey_zhouyou.util.fcs;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;

public class FCSScriptEngineFactory implements ScriptEngineFactory {

	@Override
	public String getEngineName() {
		return "FCS Script Engine";
	}

	@Override
	public String getEngineVersion() {
		return "0.10";
	}

	@Override
	public List<String> getExtensions() {
		return EXTENSIONS;
	}

	@Override
	public List<String> getMimeTypes() {
		return MIME_TYPES;
	}

	@Override
	public List<String> getNames() {
		return NAMES;
	}

	@Override
	public String getLanguageName() {
		return "FCS";
	}

	@Override
	public String getLanguageVersion() {
		return "0.10";
	}

	@Override
	public Object getParameter(String key) {
		if ("javax.script.name".equals(key))
			return "fcs";
		if ("javax.script.engine".equals(key))
			return getEngineName();
		if ("javax.script.engine_version".equals(key))
			return "0.10";
		if ("javax.script.language".equals(key))
			return "FCS";
		if ("javax.script.language_version".equals(key))
			return "0.10";
		if ("THREADING".equals(key))
			return "MULTITHREADED";

		throw new IllegalArgumentException("Invalid key");
	}

	@Override
	public String getMethodCallSyntax(String obj, String m, String... args) {
		return null;
	}

	@Override
	public String getOutputStatement(String toDisplay) {
		return null;
	}

	@Override
	public String getProgram(String... statements) {
		return null;
	}

	@Override
	public ScriptEngine getScriptEngine() {
		return new FCSScriptEngineImpl();
	}

	private static final List<String> NAMES;
	private static final List<String> EXTENSIONS;
	private static final List<String> MIME_TYPES;

	static {
		List<String> n = new ArrayList<String>(3);
		n.add("fcs");
		n.add("FCS");
		n.add("Fcs");
		NAMES = Collections.unmodifiableList(n);

		n = new ArrayList<String>(1);
		n.add("fcs");
		EXTENSIONS = Collections.unmodifiableList(n);

		n = new ArrayList<String>(1);
		n.add("application/x-fcs");
		MIME_TYPES = Collections.unmodifiableList(n);
	}
}
